package com.caishi.lkx.user.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.caishi.lkx.common.Sensitive;
import com.caishi.lkx.exam.ienum.type.MaterialType;
import com.zzw.common.entity.impl.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;


@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "sys_material_info" , autoResultMap = true)
@Schema(title = "资讯资料")
public class MaterialInfoModel extends BaseEntity<MaterialInfoModel> {

    @Schema(title = "考试id")
    private String examId;

    @Schema(title = "考试名")
    @TableField(exist = false)
    private String examName;

    @Schema(title = "行业id")
    private String industryId;

    @Schema(title = "行业名")
    @TableField(exist = false)
    private String industryName;

    @Schema(title = "科目Id")
    private Long categoryId;

    @Schema(title = "科目名称")
    @TableField(exist = false)
    private String categoryName;

    @Schema(title = "标题")
    private String title;

    @Schema(title = "别名")
    private String alias;

    @Schema(title = "排序")
    private Integer sort;

    @Schema(title = "是否置顶")
    private Boolean top;

    @Schema(title = "是否热门")
    private Boolean hot;

    @Schema(title = "类型，0.考试资讯，1.考试资料")
    private Boolean type;

    @Schema(title = "封面")
    private String cover;

    @Schema(title = "摘要")
    private String summary;

    @Schema(title = "内容")
    private String content;

    @Schema(title = "发布时间")
    private LocalDateTime releasedTime;

    @Schema(title = "作者来源")
    private String releasedBy;

    private MaterialType materialType;

    @Schema(title = "附件信息[{\"path\":\"阿里云地址\",\"size\":\"大小\",\"name\":\"资料名\"},{}]")
    @TableField(value = "attachment_infos", typeHandler = JacksonTypeHandler.class)
    private List<Map<String, Object>> attachmentInfos;

    @Schema(title = "资源大小")
    @TableField(exist = false)
    private Integer attachmentSize;

    @Schema(title = "附件下载次数")
    private Integer downloadTime;

    @Schema(title = "查看次数")
    private Integer watchTime;

    @Schema(title = "点赞次数")
    private Integer likeTime;

    @Schema(title = "创建人")
    private String createdName;

    @Schema(name = "是否点赞")
    @TableField(exist = false)
    private Boolean like;

    @Schema(name = "首页资讯置顶")
    private Boolean recommend;

    @TableField(exist = false)
    private Boolean freeFlag;

    @TableField(exist = false)
    private Long columnId;

    public String getTitle() {
        return Sensitive.replace(this.title);

    }

    public String getSummary() {
        return Sensitive.replace(this.summary);
    }

    public String getContent() {
        return Sensitive.replace(this.content);
    }



}
